﻿@page "/gateway/channel"
@namespace ThingsGateway.Gateway.Razor
@using ThingsGateway.Admin.Application
@using ThingsGateway.Admin.Razor
@using ThingsGateway.Gateway.Application
@attribute [Authorize]
@attribute [RolePermission]
@inherits ComponentDefault


<div style="height: var(--table-height);padding: 1px;margin:auto;">

    <AdminTable @ref=table TItem="Channel"
                AutoGenerateColumns="true"
                ShowAdvancedSearch=false
                AllowResizing="true"
                IsFixedHeader=true
                IsMultipleSelect=true
                SearchModel=SearchModel
                EditDialogSize="Size.ExtraLarge"
                ShowSearch="false"
                ShowExtendButtons=true
                ShowDefaultButtons=true
                ExtendButtonColumnWidth=150
                ShowExportButton="true"
                OnQueryAsync="OnQueryAsync"
                IsPagination=true
                OnSaveAsync="Save"
                OnDeleteAsync="Delete">

        <EditTemplate Context="context">
            <ChannelEditComponent Model="context"></ChannelEditComponent>
        </EditTemplate>

        <ExportButtonDropdownTemplate Context="ExportContext">
            <Button class="dropdown-item" OnClick="() => ExcelExportAsync(ExportContext)" IsDisabled=@(!AuthorizeButton("导出"))>
                <i class="fas fa-file-export"></i>
                <span>@RazorLocalizer["TablesExportButtonExcelText"]</span>
            </Button>
            <Button class="dropdown-item" OnClick="() => ExcelImportAsync(ExportContext)" IsDisabled=@(!AuthorizeButton("导入"))>
                <i class="fas fa-file-import"></i>
                <span>@RazorLocalizer["TablesImportButtonExcelText"]</span>
            </Button>
        </ExportButtonDropdownTemplate>

        <TableToolbarTemplate>
            <TableToolbarButton TItem="Channel" IsShow=@(AuthorizeButton(AdminOperConst.Edit))
                                Color=Color.Info Text="@RazorLocalizer["BatchEdit"]"
                                OnClickCallback=@(BatchEdit) />

            <TableToolbarPopConfirmButton TItem="Channel" IsShow=@(AuthorizeButton("清空"))
                                          Color=Color.Warning Text="@Localizer["Clear"]"
                                          IsAsync OnConfirm=@(ClearChannelAsync) />


        </TableToolbarTemplate>

    </AdminTable>
</div>

@code {
    AdminTable<Channel> table;
}
